/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package SPMModel.impl;

import SPMModel.Artifact;
import SPMModel.ArtifactDescriptor;
import SPMModel.ProcessDescriptor;
import SPMModel.ProcessElement;
import SPMModel.Role;
import SPMModel.RoleDescriptor;
import SPMModel.SPMModelPackage;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Process Element</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link SPMModel.impl.ProcessElementImpl#getIs <em>Is</em>}</li>
 *   <li>{@link SPMModel.impl.ProcessElementImpl#getContains <em>Contains</em>}</li>
 *   <li>{@link SPMModel.impl.ProcessElementImpl#getRole <em>Role</em>}</li>
 *   <li>{@link SPMModel.impl.ProcessElementImpl#getArtifact <em>Artifact</em>}</li>
 *   <li>{@link SPMModel.impl.ProcessElementImpl#getName <em>Name</em>}</li>
 *   <li>{@link SPMModel.impl.ProcessElementImpl#getNext <em>Next</em>}</li>
 *   <li>{@link SPMModel.impl.ProcessElementImpl#getDescription <em>Description</em>}</li>
 *   <li>{@link SPMModel.impl.ProcessElementImpl#getArtifactDescritors <em>Artifact Descritors</em>}</li>
 *   <li>{@link SPMModel.impl.ProcessElementImpl#getRoleDescriptors <em>Role Descriptors</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ProcessElementImpl extends EObjectImpl implements ProcessElement {
	/**
	 * The cached value of the '{@link #getIs() <em>Is</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIs()
	 * @generated
	 * @ordered
	 */
	protected ProcessDescriptor is;

	/**
	 * The cached value of the '{@link #getContains() <em>Contains</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getContains()
	 * @generated
	 * @ordered
	 */
	protected EList<ProcessElement> contains;

	/**
	 * The cached value of the '{@link #getRole() <em>Role</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRole()
	 * @generated
	 * @ordered
	 */
	protected EList<Role> role;

	/**
	 * The cached value of the '{@link #getArtifact() <em>Artifact</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getArtifact()
	 * @generated
	 * @ordered
	 */
	protected EList<Artifact> artifact;

	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The default value of the '{@link #getNext() <em>Next</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNext()
	 * @generated
	 * @ordered
	 */
	protected static final String NEXT_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getNext() <em>Next</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNext()
	 * @generated
	 * @ordered
	 */
	protected String next = NEXT_EDEFAULT;

	/**
	 * The default value of the '{@link #getDescription() <em>Description</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDescription()
	 * @generated
	 * @ordered
	 */
	protected static final String DESCRIPTION_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getDescription() <em>Description</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDescription()
	 * @generated
	 * @ordered
	 */
	protected String description = DESCRIPTION_EDEFAULT;

	/**
	 * The cached value of the '{@link #getArtifactDescritors() <em>Artifact Descritors</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getArtifactDescritors()
	 * @generated
	 * @ordered
	 */
	protected EList<ArtifactDescriptor> artifactDescritors;

	/**
	 * The cached value of the '{@link #getRoleDescriptors() <em>Role Descriptors</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRoleDescriptors()
	 * @generated
	 * @ordered
	 */
	protected EList<RoleDescriptor> roleDescriptors;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ProcessElementImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return SPMModelPackage.Literals.PROCESS_ELEMENT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ProcessDescriptor getIs() {
		if (is != null && is.eIsProxy()) {
			InternalEObject oldIs = (InternalEObject)is;
			is = (ProcessDescriptor)eResolveProxy(oldIs);
			if (is != oldIs) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, SPMModelPackage.PROCESS_ELEMENT__IS, oldIs, is));
			}
		}
		return is;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ProcessDescriptor basicGetIs() {
		return is;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setIs(ProcessDescriptor newIs) {
		ProcessDescriptor oldIs = is;
		is = newIs;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SPMModelPackage.PROCESS_ELEMENT__IS, oldIs, is));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<ProcessElement> getContains() {
		if (contains == null) {
			contains = new EObjectContainmentEList<ProcessElement>(ProcessElement.class, this, SPMModelPackage.PROCESS_ELEMENT__CONTAINS);
		}
		return contains;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Role> getRole() {
		if (role == null) {
			role = new EObjectResolvingEList<Role>(Role.class, this, SPMModelPackage.PROCESS_ELEMENT__ROLE);
		}
		return role;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Artifact> getArtifact() {
		if (artifact == null) {
			artifact = new EObjectResolvingEList<Artifact>(Artifact.class, this, SPMModelPackage.PROCESS_ELEMENT__ARTIFACT);
		}
		return artifact;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SPMModelPackage.PROCESS_ELEMENT__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getNext() {
		return next;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNext(String newNext) {
		String oldNext = next;
		next = newNext;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SPMModelPackage.PROCESS_ELEMENT__NEXT, oldNext, next));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDescription(String newDescription) {
		String oldDescription = description;
		description = newDescription;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SPMModelPackage.PROCESS_ELEMENT__DESCRIPTION, oldDescription, description));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<ArtifactDescriptor> getArtifactDescritors() {
		if (artifactDescritors == null) {
			artifactDescritors = new EObjectContainmentEList<ArtifactDescriptor>(ArtifactDescriptor.class, this, SPMModelPackage.PROCESS_ELEMENT__ARTIFACT_DESCRITORS);
		}
		return artifactDescritors;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<RoleDescriptor> getRoleDescriptors() {
		if (roleDescriptors == null) {
			roleDescriptors = new EObjectContainmentEList<RoleDescriptor>(RoleDescriptor.class, this, SPMModelPackage.PROCESS_ELEMENT__ROLE_DESCRIPTORS);
		}
		return roleDescriptors;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case SPMModelPackage.PROCESS_ELEMENT__CONTAINS:
				return ((InternalEList<?>)getContains()).basicRemove(otherEnd, msgs);
			case SPMModelPackage.PROCESS_ELEMENT__ARTIFACT_DESCRITORS:
				return ((InternalEList<?>)getArtifactDescritors()).basicRemove(otherEnd, msgs);
			case SPMModelPackage.PROCESS_ELEMENT__ROLE_DESCRIPTORS:
				return ((InternalEList<?>)getRoleDescriptors()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case SPMModelPackage.PROCESS_ELEMENT__IS:
				if (resolve) return getIs();
				return basicGetIs();
			case SPMModelPackage.PROCESS_ELEMENT__CONTAINS:
				return getContains();
			case SPMModelPackage.PROCESS_ELEMENT__ROLE:
				return getRole();
			case SPMModelPackage.PROCESS_ELEMENT__ARTIFACT:
				return getArtifact();
			case SPMModelPackage.PROCESS_ELEMENT__NAME:
				return getName();
			case SPMModelPackage.PROCESS_ELEMENT__NEXT:
				return getNext();
			case SPMModelPackage.PROCESS_ELEMENT__DESCRIPTION:
				return getDescription();
			case SPMModelPackage.PROCESS_ELEMENT__ARTIFACT_DESCRITORS:
				return getArtifactDescritors();
			case SPMModelPackage.PROCESS_ELEMENT__ROLE_DESCRIPTORS:
				return getRoleDescriptors();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case SPMModelPackage.PROCESS_ELEMENT__IS:
				setIs((ProcessDescriptor)newValue);
				return;
			case SPMModelPackage.PROCESS_ELEMENT__CONTAINS:
				getContains().clear();
				getContains().addAll((Collection<? extends ProcessElement>)newValue);
				return;
			case SPMModelPackage.PROCESS_ELEMENT__ROLE:
				getRole().clear();
				getRole().addAll((Collection<? extends Role>)newValue);
				return;
			case SPMModelPackage.PROCESS_ELEMENT__ARTIFACT:
				getArtifact().clear();
				getArtifact().addAll((Collection<? extends Artifact>)newValue);
				return;
			case SPMModelPackage.PROCESS_ELEMENT__NAME:
				setName((String)newValue);
				return;
			case SPMModelPackage.PROCESS_ELEMENT__NEXT:
				setNext((String)newValue);
				return;
			case SPMModelPackage.PROCESS_ELEMENT__DESCRIPTION:
				setDescription((String)newValue);
				return;
			case SPMModelPackage.PROCESS_ELEMENT__ARTIFACT_DESCRITORS:
				getArtifactDescritors().clear();
				getArtifactDescritors().addAll((Collection<? extends ArtifactDescriptor>)newValue);
				return;
			case SPMModelPackage.PROCESS_ELEMENT__ROLE_DESCRIPTORS:
				getRoleDescriptors().clear();
				getRoleDescriptors().addAll((Collection<? extends RoleDescriptor>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case SPMModelPackage.PROCESS_ELEMENT__IS:
				setIs((ProcessDescriptor)null);
				return;
			case SPMModelPackage.PROCESS_ELEMENT__CONTAINS:
				getContains().clear();
				return;
			case SPMModelPackage.PROCESS_ELEMENT__ROLE:
				getRole().clear();
				return;
			case SPMModelPackage.PROCESS_ELEMENT__ARTIFACT:
				getArtifact().clear();
				return;
			case SPMModelPackage.PROCESS_ELEMENT__NAME:
				setName(NAME_EDEFAULT);
				return;
			case SPMModelPackage.PROCESS_ELEMENT__NEXT:
				setNext(NEXT_EDEFAULT);
				return;
			case SPMModelPackage.PROCESS_ELEMENT__DESCRIPTION:
				setDescription(DESCRIPTION_EDEFAULT);
				return;
			case SPMModelPackage.PROCESS_ELEMENT__ARTIFACT_DESCRITORS:
				getArtifactDescritors().clear();
				return;
			case SPMModelPackage.PROCESS_ELEMENT__ROLE_DESCRIPTORS:
				getRoleDescriptors().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case SPMModelPackage.PROCESS_ELEMENT__IS:
				return is != null;
			case SPMModelPackage.PROCESS_ELEMENT__CONTAINS:
				return contains != null && !contains.isEmpty();
			case SPMModelPackage.PROCESS_ELEMENT__ROLE:
				return role != null && !role.isEmpty();
			case SPMModelPackage.PROCESS_ELEMENT__ARTIFACT:
				return artifact != null && !artifact.isEmpty();
			case SPMModelPackage.PROCESS_ELEMENT__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case SPMModelPackage.PROCESS_ELEMENT__NEXT:
				return NEXT_EDEFAULT == null ? next != null : !NEXT_EDEFAULT.equals(next);
			case SPMModelPackage.PROCESS_ELEMENT__DESCRIPTION:
				return DESCRIPTION_EDEFAULT == null ? description != null : !DESCRIPTION_EDEFAULT.equals(description);
			case SPMModelPackage.PROCESS_ELEMENT__ARTIFACT_DESCRITORS:
				return artifactDescritors != null && !artifactDescritors.isEmpty();
			case SPMModelPackage.PROCESS_ELEMENT__ROLE_DESCRIPTORS:
				return roleDescriptors != null && !roleDescriptors.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(", next: ");
		result.append(next);
		result.append(", description: ");
		result.append(description);
		result.append(')');
		return result.toString();
	}

} //ProcessElementImpl
